package com.whu.waterworks.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.sun.xml.internal.xsom.impl.scd.Iterators.Map;
import com.whu.waterworks.dto.WaterPlantDto;
import com.whu.waterworks.model.TWaterplantdata;
import com.whu.waterworks.model.WaterPlant;
import com.whu.waterworks.service.WaterPlantDataService;
import com.whu.waterworks.service.WaterPlantService;
import com.whu.waterworks.service.WaterPlantTypeService;
import com.whu.waterworks.util.GetObjectName;
/**
 * 水厂数据相关
 * @author wangying
 *
 */
public class GetWatetPlantData extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String waterPlantCode;//水厂编号
	private String type;
	private String beginTime;
	private String endTime;
	
	private WaterPlantDataService waterPlantDataService;
	private WaterPlantTypeService waterPlantTypeService;
	private WaterPlantService waterPlantService;
	private List<WaterPlantDto> waterPlantDtos;
	private List<String> typeNameList;
	private List<String> typeNameListEN;
	
	public String getAllWaterPlantTypeNameEN()
	{
		typeNameListEN   = waterPlantTypeService.getAllWaterPlantTypeName();
		return SUCCESS;
	}
	public String getAllTypeName()
	{
		try {
			typeNameList = waterPlantTypeService.getAllType();
			System.out.println("GetWatetPlantData typeNameList="+typeNameList.size());
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		return SUCCESS;
	}
	
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		System.out.println("GetWatetPlantData waterPlantCode="+waterPlantCode+"    type="+type+"   beginTime="+beginTime+"   endTime="+endTime);
		waterPlantDtos = new ArrayList<>();
		try {
			
			List<WaterPlantDto> waterplantdatas= waterPlantDataService.getWaterplantdatasByTwoTime(waterPlantCode, type,beginTime, endTime);
			if(waterplantdatas!=null && waterplantdatas.size()>0)
			{
				for(WaterPlantDto waterPlantDto : waterplantdatas)
				{
					WaterPlant waterPlant = waterPlantService.getWaterPlantById(waterPlantCode);					
					waterPlantDto.setStationnum(waterPlant.getWaterPlantName());
					
					waterPlantDtos.add(waterPlantDto);
				}
			}
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		return super.execute();
	}

	public String getWaterPlantCode() {
		return waterPlantCode;
	}

	public void setWaterPlantCode(String waterPlantCode) {
		this.waterPlantCode = waterPlantCode;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(String beginTime) {
		this.beginTime = beginTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public WaterPlantDataService getWaterPlantDataService() {
		return waterPlantDataService;
	}

	public void setWaterPlantDataService(WaterPlantDataService waterPlantDataService) {
		this.waterPlantDataService = waterPlantDataService;
	}

	public List<WaterPlantDto> getWaterPlantDtos() {
		return waterPlantDtos;
	}

	public void setWaterPlantDtos(List<WaterPlantDto> waterPlantDtos) {
		this.waterPlantDtos = waterPlantDtos;
	}

	public WaterPlantService getWaterPlantService() {
		return waterPlantService;
	}

	public void setWaterPlantService(WaterPlantService waterPlantService) {
		this.waterPlantService = waterPlantService;
	}

	public List<String> getTypeNameList() {
		return typeNameList;
	}

	public void setTypeNameList(List<String> typeNameList) {
		this.typeNameList = typeNameList;
	}

	public WaterPlantTypeService getWaterPlantTypeService() {
		return waterPlantTypeService;
	}

	public void setWaterPlantTypeService(WaterPlantTypeService waterPlantTypeService) {
		this.waterPlantTypeService = waterPlantTypeService;
	}
	public List<String> getTypeNameListEN() {
		return typeNameListEN;
	}
	public void setTypeNameListEN(List<String> typeNameListEN) {
		this.typeNameListEN = typeNameListEN;
	}

	
	
	

}
